import { BaseWindow } from "../../../component/window/BaseWindow";
import { Language } from "../../../../extend/language/Language";
import { GTabBar } from "../../../../com/mui/controls/GTabBar";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { ObjCreate } from "../common/ObjCreate";
import { GangFightsMainPanel } from "./GangFightsMainPanel";
import { GangFightsTeamPanel } from "./GangFightsTeamPanel";
import { GangFightsTopListPanel } from "./GangFightsTopListPanel";
import { GangFightsHistoryTopListPanel } from "./GangFightsHistoryTopListPanel";
import { PetHireInfoPanel } from "../petHire/PetHireInfoPanel";
import { PublicMessageConfig } from "../../resource/PublicMessageConfig";
import { Cache } from "../../cache/Cache";
import { MuiEvent } from "../../../../com/mui/events/MuiEvent";
import { SGangFightsMyInfo } from "../../../../Message/Public/SGangFightsMyInfo";
import { SGangFightsMyInfoEx } from "../../../../Message/Public/SGangFightsMyInfoEx";
import { SGangFightsBattles } from "../../../../Message/Public/SGangFightsBattles";
import { SGangFightsSignUp } from "../../../../Message/Public/SGangFightsSignUp";
import { SGangFightsToplist } from "../../../../Message/Public/SGangFightsToplist";
import { SGangFightsTeamInfo } from "../../../../Message/Public/SGangFightsTeamInfo";
import { SEntityId } from "../../../../Message/Public/SEntityId";
import { SLookupPlayerReply } from "../../../../Message/Game/SLookupPlayerReply";
import { GButton } from "../../../../com/mui/controls/GButton";
import { SecTimerView } from "../common/SecTimerView";
type int = number;
//class GangFightsMainWindow
    
    export  class GangFightsMainWindow extends BaseWindow
    {
        constructor()
        {
            this._tabBarData = [{"label": Language.getString(44508), "name":"mainPanel"}, {"label": Language.getString(44509), "name":"seeList"}, {"label": Language.getString(44510), "name":""}, {"label": Language.getString(44511), "name":"SecondList"}];
            super();
            setSize(838, 555);
            titleHeight = 48;
            title = Language.getString(44507);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._tabBar = new GTabBar();
            this._tabBar.horizontalGap = 1;
            this._tabBar.buttonFilters = [FilterConst.glowFilter];
            this._tabBar.dataProvider = this._tabBarData;
            this._tabBar.buttonWidth = 75;
            ObjCreate.setObjAttri(this._tabBar, 23, 34, -1, -1, this);
            this._btnHelp = ObjCreate.createGButton(Language.getString(42235), 750, 33, 70, 22, this, "Button");
            this._mainPanel = new GangFightsMainPanel();
            this._mainPanel.x = 18;
            this._mainPanel.y = 60;
            this.addChild(this._mainPanel);
            this._teamPanel = new GangFightsTeamPanel();
            this._teamPanel.x = 18;
            this._teamPanel.y = 60;
            this._topListPanel = new GangFightsTopListPanel();
            this._topListPanel.x = 18;
            this._topListPanel.y = 60;
            this._historyTopListPanel = new GangFightsHistoryTopListPanel();
            this._historyTopListPanel.x = 18;
            this._historyTopListPanel.y = 60;
            this._selectPanel = this._mainPanel;
            this._infoPanel = new PetHireInfoPanel();
            this._infoPanel.visible = false;
            this._infoPanel.x = 835;
            this._infoPanel.y = 40;
            var loc1=PublicMessageConfig.instance.getArenaTextByName("gangFightsHelpDesc");
            this._infoPanel.updateByContent(loc1);
            this.addChild(this._infoPanel);
            this.updateMyInfo(Cache.instance.gangFights.myInfo);
            this.addListeners();
            return;
        }

        /* internal  */addListeners(): void
        {
            this._tabBar.addEventListener(MuiEvent.GTABBAR_SELECTED_CHANGE, this.onTabChange);
            this._btnHelp.addEventListener(flash.events.MouseEvent.CLICK, this.onHelpBtn);
            return;
        }

        /* internal  */onTabChange(arg1: MuiEvent=null): void
        {
            var loc1=this._tabBar.selectedIndex;
            var loc2=this.getPanelByIndex(loc1);
            if (this._selectPanel && this._selectPanel.parent) 
            {
                this._selectPanel.parent.removeChild(this._selectPanel);
            }
            this.addChild(loc2);
            this._selectPanel = loc2;
            return;
        }

        /* internal  */onHelpBtn(arg1: Object /* flash.events.MouseEvent */): void
        {
            this._infoPanel.visible = !this._infoPanel.visible;
            return;
        }

        /* internal  */getPanelByIndex(arg1: int): Object /* flash.display.DisplayObject */
        {
            var loc1=arg1;
            switch (loc1) 
            {
                case 0:
                {
                    return this._mainPanel;
                }
                case 1:
                {
                    return this._teamPanel;
                }
                case 2:
                {
                    return this._topListPanel;
                }
                case 3:
                {
                    return this._historyTopListPanel;
                }
                default:
                {
                    return this._mainPanel;
                }
            }
        }

        public updateMyInfo(arg1: SGangFightsMyInfo): void
        {
            if (arg1) 
            {
                this._mainPanel.updateMyInfo(arg1);
                this._teamPanel.updateVisible();
                if (arg1.isNewCross) 
                {
                    title = Language.getString(44595);
                }
                else 
                {
                    title = Language.getString(44507);
                }
            }
            return;
        }

        public updateMyInfoEx(arg1: SGangFightsMyInfoEx): void
        {
            this._mainPanel.updateMyInfoEx(arg1);
            return;
        }

        public updateBattles(arg1: SGangFightsBattles): void
        {
            this._mainPanel.updateBattles(arg1);
            return;
        }

        public updateSignUpState(arg1: SGangFightsSignUp): void
        {
            this._mainPanel.updateSignUpState(arg1);
            return;
        }

        public changeToTab(arg1: int): void
        {
            this._tabBar.selectedIndex = arg1;
            this.onTabChange();
            return;
        }

        public updateTopList(arg1: SGangFightsToplist): void
        {
            this._teamPanel.updateTopList(arg1);
            this._topListPanel.updateTopList(arg1);
            this._historyTopListPanel.updateTopList(arg1);
            return;
        }

        public updateTeamInfo(arg1: SGangFightsTeamInfo): void
        {
            this._teamPanel.updateTeamInfo(arg1);
            return;
        }

        public updateMoeny(): void
        {
            this._mainPanel.updateMoeny();
            return;
        }

        public updateAccount(): void
        {
            this._mainPanel.updateAccount();
            return;
        }

        public setPlayerNotOnline(arg1: SEntityId): void
        {
            this._teamPanel.setPlayerNotOnline(arg1);
            return;
        }

        public updateTeamPlayerInfo(arg1: SLookupPlayerReply): void
        {
            this._teamPanel.updateTeamPlayerInfo(arg1);
            return;
        }

        public close(): void
        {
            this._mainPanel.reset();
            return;
        }

        public static get instance(): GangFightsMainWindow
        {
            if (!GangFightsMainWindow._instance) 
            {
                GangFightsMainWindow._instance = new GangFightsMainWindow();
            }
            return GangFightsMainWindow._instance;
        }

        public static hasInstance(): Boolean
        {
            return !(GangFightsMainWindow._instance == null);
        }

        /* internal */ /* var */_tabBar: GTabBar;

        /* internal */ /* var */_selectPanel: Object /* flash.display.DisplayObject */;

        /* internal */ /* var */_tabBarData: Array<any>;

        /* internal */ /* var */_btnHelp: GButton;

        /* internal */ /* var */_infoPanel: PetHireInfoPanel;

        /* internal */ /* var */_mainPanel: GangFightsMainPanel;

        /* internal */ /* var */_teamPanel: GangFightsTeamPanel;

        /* internal */ /* var */_topListPanel: GangFightsTopListPanel;

        /* internal */ /* var */_historyTopListPanel: GangFightsHistoryTopListPanel;

        /* internal */ /* var */_timeView: SecTimerView;

        /* internal */ static /* var */_instance: GangFightsMainWindow;
    }
